<!-- <!doctype html>
<html>
  <head>
    <title>Socket.IO chat</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//cdn.bootcss.com/c3/0.4.11/c3.css" rel="stylesheet">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
  </head>
  <body>

    <h1>你好，世界！</h1>
    <div id="chart"></div>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="//cdn.bootcss.com/c3/0.4.11/c3.js"></script>
    <script src="javascripts/socket.io.js"></script>
    <script src="//cdn.bootcss.com/jquery/3.1.0/jquery.js"></script>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script>
      var list = ['留言量'];
      var listX = ['x'];
      var listWordCount = ['情绪量'];
      var socket = io();

      // 向服务器推送
      // setInterval(function() {
      //   socket.emit('chat message', '智齿科技');
      // }, 3000);
      var chart = c3.generate({

        data: {
          x: 'x',
          columns: [
            listX ,
            list ,
            listWordCount
          ]
        },
        axis: {
          x: {
              type: 'timeseries',
              tick: {
                  format: '%H:%m:%S',
              }
          }
        }
      });

      socket.on('chat message', function(msg){

        console.log(JSON.parse(msg)[0]);
        listX.push(JSON.parse(msg)[0].dataLine);
        list.push(JSON.parse(msg)[0].data.length);
        listWordCount.push(JSON.parse(msg)[0].wordCount);
        // console.log(list);
        console.log(listX)
        chart.load({
          columns: [
            listX ,
            list ,
            listWordCount
          ],
          type: 'spline'
        })
      });
    </script>
  </body>
</html> -->




























<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Starter Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="http://v3.bootcss.com/examples/starter-template/starter-template.css" rel="stylesheet">

    <link href="//cdn.bootcss.com/c3/0.4.11/c3.css" rel="stylesheet">
    <!-- <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css"> -->
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">

      <div class="starter-template">
        <h1>000001 上证指数</h1>
        <p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
        <div id="chart"></div>
      </div>

    </div><!-- /.container -->

    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script src="//cdn.bootcss.com/c3/0.4.11/c3.js"></script>
    <script src="javascripts/socket.io.js"></script>
    <script src="//cdn.bootcss.com/jquery/3.1.0/jquery.js"></script>
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script>
      var list = ['留言量'];
      var listX = ['x'];
      var listWordCount = ['情绪量'];
      var socket = io();

      // 向服务器推送
      // setInterval(function() {
      //   socket.emit('chat message', '智齿科技');
      // }, 3000);
      var chart = c3.generate({

        data: {
          x: 'x',
          columns: [
            listX ,
            list ,
            listWordCount
          ]
        },
        axis: {
          x: {
              type: 'timeseries',
              tick: {
                  format: '%H:%m:%S',
              }
          }
        }
      });

      socket.on('chat message', function(msg){

        console.log(JSON.parse(msg)[0]);
        listX.push(JSON.parse(msg)[0].dataLine);
        list.push(JSON.parse(msg)[0].data.length);
        listWordCount.push(JSON.parse(msg)[0].wordCount);
        // console.log(list);
        console.log(listX)
        chart.load({
          columns: [
            listX ,
            list ,
            listWordCount
          ],
          types: {
             '留言量': 'area-spline',
             '情绪量': 'area-spline'
             // 'line', 'spline', 'step', 'area', 'area-step' are also available to stack
          },
        })
      });
    </script>
  </body>
</html>
